package com.jumi.microservice.order.factory;

import com.jumi.microservice.dto.order.CreateOrderRequest;
import com.jumi.microservice.order.context.OrderCreateContext;
import com.jumi.microservice.order.context.TransHandlerContext;
import com.jumi.microservice.order.convert.OrderConvert;
import com.jumi.microservice.order.convert.TransConvert;
import com.jumi.microservice.order.handler.*;
import com.jumi.microservice.order.pipeline.TransPipeline;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author Dirk
 * @Date 2020-08-05 13:55
 */
@Component
public class BuyProductPipelineFactory extends AbstractTransPipelineFactory<CreateOrderRequest> {

    @Resource
    ValidateHandler validateHandler;

    @Resource
    BuyProductInitHandler buyProductInitHandler;

    @Resource
    private SplitOrderHandler splitOrderHandler;

    @Resource
    OrderCreateLogisticalHandler orderCreateLogisticalHandler;

    @Resource
    ActivityHandler activityHandler;


    @Override
    protected void doBuild(TransPipeline pipeline) {
        pipeline.addLast(validateHandler);
        pipeline.addLast(buyProductInitHandler);
        pipeline.addLast(activityHandler);
        pipeline.addLast(splitOrderHandler);
        pipeline.addLast(orderCreateLogisticalHandler);
    }

    @Override
    protected TransHandlerContext createContext() {
        return new OrderCreateContext();
    }

    @Override
    protected TransConvert createConvert() {
        return new OrderConvert();
    }
}